package gld.algo.tlc;

import gld.*;
import gld.sim.*;
import gld.algo.tlc.*;
import gld.infra.*;
import gld.utils.*;
import gld.xml.*;

import java.io.IOException;
import java.util.* ;
import java.awt.Point;

public class SOTLC extends TLController
{	protected int num_nodes;
	protected final static String shortXMLName="tlc-selforganized";

	public SOTLC(Infrastructure i) {
	    super(i);
	}
	
	@Override
	public TLDecision[][] decideTLs() {
		int num_lanes;
		
		for (int i=0; i < num_nodes; i++) {
			num_lanes = tld[i].length;
			for(int j=0; j < num_lanes; j++) {
				tld[i][j].setQValue(tld[i][j].getTL().getLane().getNumRoadusersWaiting());
    			}
		}
		return tld;
	}
	@Override
	public void updateRoaduserMove(Roaduser _ru, Drivelane _prevlane,
			Sign _prevsign, int _prevpos, Drivelane _dlanenow, Sign _signnow,
			int _posnow, Drivelane[] _possiblelanes, Point[] _ranges,
			Drivelane lane) {
		// TODO Auto-generated method stub
		
	}

	public XMLElement saveSelf () throws XMLCannotSaveException
	{ 	XMLElement result=super.saveSelf();
		result.setName(shortXMLName);
		return result;
	}
	
	
	@Override
	public String getXMLName() {
		return "model."+shortXMLName;
	}
	
}
